Realizing quantum convolutional neural networks on a superconducting quantum processor to recognize quantum phases

Quantum computing crucially relies on the ability to efficiently characterize the quantum states output by quantum hardware. Conventional methods which probe these states through direct measurements and classically computed correlations become computationally expensive when increasing the system size. Quantum neural networks tailored to recognize specific features of quantum states by combining unitary operations, measurements and feedforward promise to require fewer measurements and to tolerate errors. Here, we realize a quantum convolutional neural network (QCNN) on a 7-qubit superconducting quantum processor to identify symmetry-protected topological (SPT) phases of a spin model characterized by a non-zero string order parameter. We benchmark the performance of the QCNN based on approximate ground states of a family of cluster-Ising Hamiltonians which we prepare using a hardware-efficient, low-depth state preparation circuit. We find that, despite being composed of finite-fidelity gates itself, the QCNN recognizes the topological phase with higher fidelity than direct measurements of the string order parameter for the prepared states.

R emarkable progress in building quantum hardware [1][2][3][4] has fueled the search for potential applications of both nearterm and future error-corrected quantum computers 5,6 , particularly in the simulation of quantum many-body systems 7,8 and in machine learning [9][10][11][12] . For example, the ability of quantum computers to perform linear algebraic operations more efficiently could provide potential speedups for classical machine learning tasks, such as the ordinary matrix inversion in linear regression models 13 . However, dedicated quantum algorithms for this purpose, such as the Harrow, Hassidim and Lloyd algorithm 14 , rely both on executing deep quantum circuits 15 and on loading binary data into a quantum register 16 to offer practical advantages, which is beyond the reach of currently available quantum hardware. To load classical data into a quantum register in a more resource-efficient manner and map their features into the highdimensional Hilbert space to ease classification, quantum circuits parameterized by the input data have been devised and used in quantum support vector machines 17,18 and quantum neural networks 19 . However, independent of the specific data embedding scheme, it is still an open question whether tasks aiming at the analysis of classical data can ever fully leverage a quantum computer's capability to process classically unrepresentable amounts of data 9 .
Promising candidates to harness the capabilities of near-term quantum computers are therefore algorithms which process quantum data directly and for which there is no classical analog 9,20 . Quantum computers are beginning to reach a level at which their output states are too complex to be analyzed by classical means 1 , suggesting that machine learning techniques which directly process quantum data are expected to become an increasingly important tool to efficiently characterize and benchmark quantum hardware. Examples of specific applications thereof include the principal component analysis of density matrices 21 , quantum autoencoders [22][23][24] , the certification of Hamiltonian dynamics 25,26 , and the detection of entanglement correlations in quantum many-body states 10,11,[27][28][29] .
In this work, we experimentally demonstrate the classification of quantum states with quantum neural networks 11 by implementing a quantum algorithm designed to recognize signatures of topological quantum phases [30][31][32] . This challenging task is of great relevance for the study of quantum many-body systems 33 such as high-temperature superconductors 34 . Previous work in this context has focused on recognizing topological quantum phases from (simulated) measurement data using classical machine learning techniques [35][36][37][38] . Furthermore, topological states have recently been prepared on quantum hardware and analyzed by measuring characteristic observables 39-41 such as string order parameters. Here, we experimentally demonstrate a new paradigm to detect symmetry-protected topological states on a 7-qubit quantum device by preparing quantum states within and outside of the SPT phase and by further processing these states with a quantum convolutional neural network to perform quantum phase recognition. We have designed and experimentally implemented a QCNN that, despite being composed of finite-fidelity gates itself, outperforms the direct measurement of the string order parameter in correctly identifying the topological phase. This enhanced capability is achieved by constructing the QCNN to simultaneously measure a weighted sum of Pauli strings, the number of which grows exponentially with the system size N (see Supplementary Note 5). The structure of this effectively measured observable allows the QCNN to tolerate both X-and Z-type errors while processing weakly perturbed input states. Using the QCNN to measure this observable circumvents the need to measure its constituent terms individually.

Results
Model. As a model system we consider a family of cluster-Ising Hamiltonians 42 : Ground states of (1) either belong to a topological quantum phase, a paramagnetic (PM) phase, or an antiferromagnetic phase depending on the model parameters {h 1 , h 2 }. h 1 and h 2 parametrize the strength of an external field and a nearestneighbor Ising-type coupling in the model. {X i , Y i , Z i } are the Pauli operators acting on the spin at site i. We define Z 0 Z Nþ1 X Nþ1 1, which models a spin chain with open boundary conditions 41 .
In the thermodynamic limit, the bulk of the Hamiltonian H commutes with both even P e = ∏ i X 2i and odd P o = ∏ i X 2i + 1 parity operators, and thus exhibits a Z 2 Z 2 symmetry-protected topological quantum phase 43 , which falls into the same symmetry class as the S = 1 Haldane phase 44 . The SPT phase is distinguished from the paramagnetic and antiferromagnetic phase by a non-zero expectation value S h i of the string order parameter 32 : which is defined for an odd number of spins N. Corresponding to the experimental situation in this work, we have computed S h i, shown in Fig. 1a, using exact diagonalization for a system of N = 7 spins. Due to the finite system size, we obtain smooth transitions across the phase boundaries (white dashed lines) determined from the maxima in the second derivative of the energy expectation value 〈H〉 with respect to h 2 33 .
Concept of the experiment. Conventionally, the phase to which an unknown quantum state ρ belongs is determined by measuring the expectation value of an order parameter S, a process referred to as quantum phase recognition. However, when evaluating the expectation value S h i by simultaneously, but individually measuring the qubits in their respective basis and by averaging the outcomes over multiple repetitions of the experiment, the sampling complexity increases close to the phase boundaries 11 . Furthermore, under realistic conditions the state ρ, which we prepare on the quantum hardware by executing a state-preparation circuit, might be subject to errors, reducing the value of hSi.
To overcome the aforementioned limitations, we perform quantum phase recognition by processing the trial states ρ with a QCNN. The structure of QCNNs, as recently proposed in Ref. 11 , is inspired by classical convolutional neural networks widely used e.g., in image or speech recognition. A generic QCNN consists of alternating convolutional (C) and pooling (P) layers, followed by a fully-connected (FC) layer, as schematically shown in Fig. 1b. The combination of entangling gates applied between neighboring qubits in the convolutional layer, and single-qubit gates conditioned on the outcome of projective measurements in the pooling layer, reduces the number of qubits while retaining characteristic features of the input state vector. After repeating this procedure d times, a unitary operation in the FC layer maps the feature of interest onto a single output qubit. In general, QCNNs are parameterized and can be trained to identify specific features of interest.
In our particular case, the QCNN is designed to recognize string order and decide if the input state ρ belongs to the symmetry-protected topological phase or not. Instead of measuring the single string order parameters S as defined in Eq. (2), the output of the QCNN corresponds to the weighted sum of multiple string order parameters, the value of which is robust against local X and Z-type errors. The specific structure of the QCNN is inspired by the multiscale entanglement renormalization ansatz representation 45 of the topological cluster state, which is the ground state of In this case, each pair of convolutional and pooling layers maps a (perturbed) cluster state onto a cluster state of reduced system size, see Supplementary Note 5 for more details. Compared to the originally proposed QCNN 11 , we modify the FC layer to augment its tolerance to errors and use several gate identities to implement operations in the P and FC layers in classical processing wherever possible. We thereby drastically reduce the quantum gate count and enhance the performance of the QCNN under NISQ conditions. For our experimental study carried out on a 7-qubit device, we combine two complementary elements. First, we prepare approximate ground states of the cluster-Ising Hamiltonian H by executing variational state preparation circuits. Second, we use those states as an input to the QCNN to demonstrate its capability to recognize the SPT phase and compare it to directly measuring 〈S〉.
Variational state preparation. To prepare approximate ground states of the gapped one-dimensional Hamiltonian H 44 for the entire parameter range {h 1 , h 2 } displayed in Fig. 1a, we use a lowdepth, variational state preparation circuit U(θ) composed of three layers of single-qubit rotations R y (θ i ) parametrized by 19 independent rotation angles θ i and two layers of conditional-Z (CZ) gates interleaved with the single-qubit gates, see Fig. 2a 46 . We implement both types of gates directly on the quantum hardware, see Supplementary Note 4 in which we also provide a comparison to an alternative approach used in Ref. 39 to prepare ground states via an exact matrix product state representation of translationally invariant states.
To determine the variational parameters θ = {θ 1 , ..., θ 19 } corresponding to an approximate ground state of a specific H(h 1 , h 2 ), we minimize the energy expectation value H h i in a conventional computer simulation with respect to the simulated output state θ j i ¼ UðθÞ 0 j i by using a gradient based L-BFGS  optimizer 47 . As an acceptance criterion for the convergence of the optimization algorithm, we compute the fidelity F ¼ jhψ 0 jθ opt ij 2 of the variational state jθ opt i with respect to the exact ground state ψ 0 , which, for N = 7, can be found using exact diagonalization. We repeat the optimization procedure with different initial values until F exceeds 81% solely being limited by the finite variational circuit depth of m = 1, see Supplementary Note 4. To make the state preparation circuit less susceptible to T 1 errors, we then compute an equivalent set of rotational anglesθ opt yielding the same Uðθ opt Þ ¼ Uðθ opt Þ 48 , but keeping the individual qubits preferentially in their respective ground state in the beginning of the state preparation sequence, see Supplementary Note 4 for details. This procedure avoids rotation angles close to π in the first layer of single-qubit rotations, which becomes apparent in the three examples shown in Fig. 2b by the absence of large rotation angles in the first column. The example state from the PM phase features rotation angles summing to~±π/2 for each qubit individually. For the example state from the SPT phase, all qubits are initially rotated by an angle close to ±π/2, which, together with the subsequent layers of entangling CZ gates, results in an approximate cluster state 41 .
For the rotation anglesθ opt found in computer simulation, we execute the corresponding state preparation circuits on a 7-qubit superconducting quantum device featuring individual control and readout of all qubits, see Supplementary Note 1 for details. We realize single-qubit rotations by applying microwave pulses of controlled amplitude and phase and implement two-qubit CZ gates with flux pulses bringing the state 11 j i into resonance with the non-computational state 20 j i 49,50 , where jn i ; n j i denote the states of the involved qubits in the Fock basis. To assure that all qubits are in their respective ground state at the beginning of each sequence, we perform a preselection readout and reject those measurement runs in which we found at least one of the qubits to be in the excited state, resulting in an overall acceptance probability of~91%. We perform measurements in the X basis by prepending an R y (π/2) rotation to the respective qubits before performing standard dispersive readout in the Z basis. To mitigate the effect of readout infidelities on the order of 1.6% per qubit in averaged measurement observables, we multiply the vector of probabilities p i of sampling the bitstring x i by the inverse of the assignment probability matrix M to obtainp ¼ M À1 p, from which we evaluate expectation values, see Supplementary Note 2 for details.
To characterize our state preparation, we measure a set of local expectation values and compare the results with those obtained from Kraus operator simulations, which take qubit dissipation and dephasing, as well as measured CZ gate errors and nearestneighbor residual ZZ coupling into account, see Fig. 2c. For states in the paramagnetic (antiferromagnetic) phase, we find, as expected, a non-zero magnetization hX i i along the entire spin chain with equal (alternating) sign. The key signature of states in the SPT phase is the non-zero expectation value of Pauli strings Z iÀ1 X i Z iþ1 . In all three cases, the average deviation between measured and simulated expectation values is below 5.8% and can likely be attributed to small additional coherent control errors, which we do not account for in the Kraus operator simulation.
To map out the full quantum phase diagram shown in Fig. 2d, we proceed with measuring the string order parameter S h i for 10 × 10 combinations of {h 1 , h 2 } by directly sampling 32,768 times from the output of the state preparation circuit as indicated in Fig. 3a. We find the measured phase diagram to show all qualitative features of the exactly calculated one shown in Fig. 1a. The reduction in the overall contrast, which becomes apparent in the different amplitude scaling of hSi, stems from errors due to decoherence and two-qubit gate errors as confirmed by Kraus operator simulations, see Supplementary Note 4 for details. Most importantly, some of those errors can be tolerated when inferring the quantum phase of a prior unknown state by applying a QCNN algorithm rather than measuring S h i directly, as we show in the following.
Quantum phase recognition. Instead of measuring the expectations S h i directly after state preparation, we now employ the QCNN to detect the SPT phase. For this purpose, we process the prepared quantum states by the QCNN depicted in Fig. 3b and evaluate the expectation value 2〈y〉 − 1 of the single output bit y, which corresponds to measuring the expectation value of a multiscale string order parameter S M consisting of a weighted sum of Pauli strings, see Eq. (14) in Supplementary Note 5 for an explicit expression. Measuring the QCNN output S M ¼ 2y À 1 instead of S is advantageous because weakly perturbed cluster states still yield S M ¼ þ1 while the same states have a finite probability to yield S ¼ À1 which reduces the fidelity of the respective expectation value. Due to this property, S M attains a step-like behavior at phase boundaries for large system sizes leading to a reduced sampling complexity 11 . Using the QCNN allows us to measure all the individual strings in S M simultaneously, thereby reducing the number of measurement terms compared to a direct sampling of all Pauli strings, by an amount which scales exponentially with the QCNN system size N. For the system size N = 7 considered in our experiment the number of individual strings in S M is 10, see Supplementary Note 5 for details.
We construct the QCNN by making two modifications to the quantum circuit proposed in Ref. 11 . First, we perform the pooling and fully-connected layers as a Boolean function f(x) after having performed a projective measurement. This approach requires only a constant depth quantum circuit irrespective of the qubit number, which greatly reduces the total quantum gate count in comparison to preceding QCNN circuits while yielding the same output value. We explicitly show in Supplementary Note 5 that the modified QCNN circuit is fully equivalent to the original circuit in which all operations are implemented with quantum gates. While this modification is applicable to the exact QCNN circuit optimized for our particular model system, the implementation of a generic parametrized QCNN may not allow for a similar reduction of quantum gates. Second, we extend the Fig. 3 Quantum phase recognition circuits. a Quantum circuit for the case in which the qubits are measured in the indicated basis, directly after executing the state preparation circuit U(θ), to evaluate S ¼ Z 1 X 2 X 4 X 6 Z 7 . b QCNN circuit consisting of a convolutional layer (C) of CZ gates (orange), and a pooling (P) and fully-connected (FC) layer implemented as a measurement in the X basis with outcome x, followed by a Boolean function f(x), here, represented by a logic circuit expressed in terms of AND and XOR gates (purple). An example of an X (Z) error occurring on qubit six (four) and its propagation through the QCNN is highlighted in red (blue).
fully-connected layer to map the measured bitstring x = (x 1 , x 3 , x 4 , x 5 , x 7 ) onto a single output bit y, such that it not only tolerates X errors, but also Z errors, provided the errors are sufficiently sparse. For example, an X error occurring on qubit six and a Z error on qubit four prior to the convolutional layer invert bits x 5 , x 7 and x 4 , which is corrected by the function f(x), see the red and blue colored paths in Fig. 3b. With this modification, the number of measurements that would be needed to determine hS M i without employing the QCNN is also much larger than in previously proposed versions 11 , for which all the involved Pauli strings can be obtained from measuring in only two different bases, see Supplementary Note 5. The constant-depth quantum circuit plays a crucial role in the QCNN as it allows us to simultaneously sample all quasi-local observables Z i−1 X i Z i+1 . The samples contain information about the long-range correlations between these quasi-local observables, which enables us to efficiently determine hS M i using classical processing.
To investigate the QCNN's tolerance to errors in more detail, we sample x after having performed the convolutional layer for two different ground states chosen from the SPT and PM phase, respectively, and obtain the probability distributions shown in Fig. 4a. For the state in the SPT phase (top panel), we find a high probability of 0.47 to sample (00000), which is expected because the ideal cluster state corresponding to the ground state of H(h 1 = h 2 = 0) is mapped onto þþþþþ j iby the disentangling CZ gates of the quantum convolutional layer. However, due to the non-zero value of h 1 = 0.2 and the presence of noise in the quantum circuit, we also measure other bitstrings with non-zero probability, most notably (10000). Most importantly, a large fraction of those bitstrings is correctly mapped onto y = 1 by the function f, thereby counteracting a quantum phase misclassification in those cases. For the paramagnetic example (bottom panel), we find the sampled bitstrings to be more uniformly distributed and, correspondingly, y to result equally likely in 0 or 1. In both examples, we find the measured probability distributions to be in good agreement with the simulated ones, taking decoherence, two-qubit gate imperfections and readout errors into account.
We finally quantify the performance of the QCNN in correctly identifying the SPT phase by comparing the value 2〈y〉 − 1 obtained from the QCNN to the value S h i obtained from direct sampling, see Fig. 4b, c. In particular, we determine both quantities across the phase boundaries separating the SPT phase (light gray) from the paramagnetic and antiferromagnetic phases, respectively, by varying h 2 for constant h 1 = 0.2. In both cases the measured expectation values (dots), which we obtain from 32,768 individual samples, approach zero for the paramagnetic and antiferromagnetic phases and take a non-zero value reaching 0.70 in the SPT phase. Compared to the ideal values (solid lines) and as a result of error events, the overall fidelity is reduced -an effect which is well-explained by Kraus operator simulations of the respective quantum circuits (dashed lines), which also identify two-qubit gate imperfections as the most prominent error contributor, see Supplementary Note 4 for details on the simulations. Most importantly, we find the average difference of the measured QCNN output values 2〈y〉 − 1 from the ideal curve to be 0.23, while the average difference of the directly measured values of S h i is 0.34. This enhancement of performance provides clear evidence for the robustness of the QCNN against errors.

Discussion
By implementing a QCNN on a superconducting quantum processor, we have demonstrated its capability to efficiently recognize quantum phases. With further advances in qubit number and circuit depth, we expect QCNNs to become an important diagnostic tool to characterize output states of NISQ devices, which are increasingly challenging to analyze with classical computing. Such applications will benefit from the predicted increased sampling complexity at phase boundaries 11 , at which the QCNN enhances the distinguishing power for assigning states to different quantum phases. While this enhancement is not yet accessible for the system size considered here, larger systems will be able to benefit from it, see Supplementary Note 5. Additionally, the scaling advantage can be understood by expressing the output of a QCNN by an equivalent weighted sum of string order parameters, the number of which scales exponentially with N. The QCNN thus allows one to simultaneously measure the sum of all those terms. An interesting direction to be explored in future work includes the trainability of parameterized QCNNs. This also becomes relevant in the context of using QCNNs to learn optimal strategies for quantum error correction.

Data availability
The authors declare that the data supporting the findings of this letter and corresponding Supplementary